#version 460
#extension GL_GOOGLE_include_directive : enable
#extension GL_EXT_scalar_block_layout : enable
#extension GL_EXT_buffer_reference2 : require
#extension GL_EXT_shader_explicit_arithmetic_types_int64 : require

#include "../../../../core/shader_binding_ID.h"
#include "../../../../core/shader_ray.h"

#include "../../../../core/shader_std.h" 
#include "../../../../core/shader_curve.h" 

layout(buffer_reference, scalar) readonly buffer R_GlobalParameter { S_GlobalParam GlobalParamAddress[]; };
layout(buffer_reference, scalar) readonly buffer R_GlobalParameter_CurevPoint { S_CurvePoint  curvePointPtr[]; };
layout(binding = DEF_BINDING_Render_GlobalParam, scalar) readonly buffer B_GlobalParam { S_GlobalParam gGlobalParam; };
layout(binding = DEF_MaterialsBindID, scalar) readonly buffer B_Material { S_Material m_Material[]; };

#include "../../../../core/shader_PBR.h"
#include "../../../../core/shader_texture.h"
#include "../../../../core/shader_sample.h"
#include "../../../../core/shader_noise.h"


layout(binding = DEF_TasterTexturesBindID_rgba8) uniform sampler2D Ts[]; 
layout(location = 0) in vec4 vColor;
layout(location = 1) in vec3 vNormal;
layout(location = 2) in vec3 vCamera[4];
layout(location = 8) in flat uint gPrimitiveID;
layout(location = 9) in flat uint gMeshOffset;

layout(location = DEF_BINDING_LocationBindID_Vert) in vec3 vVert;
layout(location = DEF_BINDING_TasterBindID_MaterialID) in flat S_FaceAttr Element;


layout(location=0) out vec4 outColor;

//layout(binding = DEF_TasterTexturesBindID_rgba8, rgba8) uniform image2D Ts[];
//layout(binding = DEF_TasterTexturesBindID_rgba32f, rgba32f) uniform image2D Ts_rgba32f[];


void main(void) {
	S_SceneDataCall callSceneData;

	float d = (dot(vCamera[0], vNormal)) + 1.0;
	float PN = dot(vCamera[0], vNormal);

	//vec4 Color = f_glsl_buildColor(InstanceColor[vInstanceIndex]);
	//gl_BaseInstance;
	outColor = vec4(vColor.rgb * d * 0.5, vColor.a);
	outColor = vec4(1,0,1,1);
	//outColor.rgb += vec3(0.2, 0.21, 0.22) * d;
	/*if(PN >= 0){
		outColor.rgb = vec3(0,0,1);
	} else {
		outColor.rgb = vec3(1,0,0);
	}*/
	//float ds = DepthScale;
	//ds = 1;
	//gl_FragDepth = gl_FragCoord.z * ds;
	gl_SamplePosition[0];
}



